import request from "@/utils/request";
import { AxiosPromise } from "axios";
import {
  ReplyWokeFrom,
  ViewWokeFrom,
  ViewWokeFromData,
  WokeDeleteFrom,
  WokeFrom,
  WokePageVO,
  WorkTypeQuery,
} from "./types";

/**
 * 工单分页列表
 *
 * @param queryParams
 */
export function getWokeTypePage(
  queryParams: WorkTypeQuery
): AxiosPromise<PageResult<WokePageVO[]>> {
  return request({
    url: "/api/v1/system/questions/all",
    method: "get",
    params: queryParams,
  });
}

/**
 * 添加工单
 *
 * @param queryParams
 */
export function AddWoke(queryParams: WokeFrom): AxiosPromise<WokeFrom> {
  return request({
    url: "/api/v1/system/questions/add",
    method: "post",
    params: queryParams,
  });
}

/**
 * 撤回工单
 *
 * @param queryParams
 */
export function RemoveWoke(queryParams: WokeDeleteFrom): AxiosPromise<void> {
  return request({
    url: "/api/v1/system/questions/delete",
    method: "delete",
    params: queryParams,
  });
}

/**
 * 查看工单详情信息
 *
 * @param queryParams
 */
export function ViewWoke(
  queryParams: ViewWokeFrom
): AxiosPromise<ViewWokeFromData> {
  return request({
    url: "/api/v1/system/questions/view",
    method: "get",
    params: queryParams,
  });
}

/**
 * 管理员回复工单
 *
 * @param queryParams
 */
export function ReplyWoke(queryParams: ReplyWokeFrom): AxiosPromise<void> {
  return request({
    url: "/api/v1/system/questions/handling",
    method: "patch",
    params: queryParams,
  });
}
